'''
# @Title:
# @Time : 2022/3/17 15:55
# @File : Test_Department.py
# @Software: PyCharm

'''
import allure
import pytest
import requests


@allure.feature("企业微信部门管理测试")
class TestWeWork:

    def setup_class(self):
        '''
        获取access_tooken
        :return:
        '''
        corpid = "ww3d5aaa86c9e639ba"
        corpsecret = "vetPDZF55FiQqc5oVW-iumcGJBFIINthyrnbsLkNOFI"
        url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken'
        params = {
            "corpid":corpid,
            "corpsecret":corpsecret
        }

        r = requests.get(url,params=params)
        access_token = r.json()['access_token']
        self.access_token = access_token

    '''
    创建部门
    '''
    @allure.story("创建部门用例")
    @pytest.mark.parametrize("")
    def test_creat_department(self):
        url = f'https://qyapi.weixin.qq.com/cgi-bin/department/create?access_token={self.access_token}'
        data ={
            "name": "广州研发中心",
            "name_en": "RDGZ",
            "parentid": 1,
            "order": 1,
            "id": 2
        }
        res = requests.request(method='post', url=url, json=data)
        print(res.text)




















